package com.cloud.drore.eboss.sso.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.cloud.drore.eboss.sso.base.BaseEntity;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.List;


@Entity
@Table(name = "eboss_user")
@Data
public class ShiroUser extends BaseEntity<Long> {

    @JsonProperty("username")
    @Column(name = "username")
    @ApiModelProperty(name = "username", notes = "用户名", example = "angela")
    private String username;

    @JsonProperty("name")
    @JSONField(name = "name")
    @ApiModelProperty(name = "name", notes = "姓名", example = "angela")
    private String name;
    @ApiModelProperty(name = "password", notes = "密码", example = "angela")
    private String password;
    @ApiModelProperty(name = "job", notes = "岗位", example = "区域经理")
    private String job;
    private Integer status;//用户状态:0-注册用户未审核，1-注册用户已审核 ，2-锁定
    @Column(name = "tenant_id")
    @JsonProperty("tenant_id")
    @JSONField(name = "tenant_id")
    @ApiModelProperty(name = "tenant_id", notes = "租户", example = "1")
    private Long tenantId;
    @Column(name = "is_admin")
    @JsonProperty("is_admin")
    @JSONField(name = "is_admin")
    @ApiModelProperty(name = "is_admin", notes = "0普通用户,1超级用户", example = "0")
    private int isAdmin;
    @ApiModelProperty(name = "type", notes = "DEALER,OPERATION,SUPPLIER", example = "DEALER")
    private String type;
    @Column(name = "type_industry")
    @JsonProperty("typeIndustry")
    @JSONField(name = "typeIndustry")
    @ApiModelProperty(name = "typeIndustry", notes = "商户行业", example = "1")
    private String typeIndustry;
    @Column(name = "type_id")
    @JsonProperty("type_id")
    @JSONField(name = "type_id")
    @ApiModelProperty(name = "type_id", notes = "商户id", example = "1")
    private Long typeId;
    @ApiModelProperty(name = "phone", notes = "手机号码", example = "13565478954")
    private String phone;
    @ApiModelProperty(name = "email", notes = "邮箱", example = "13565478954@qq.com")
    private String email;
    @Column(name = "show_imge")
    @JsonProperty("show_imge")
    @JSONField(name = "show_imge")
    @ApiModelProperty(name = "show_imge", notes = "头像", example = "https://ss0.baidu.com/6ONWsjip0QIZ8tyhnq/it/u=3643687533,272026720&fm=58")
    private String showImge;
    @Transient
    @ApiModelProperty(hidden = true)
    private List<EbossRoleRightRelation> rightList;// 一个用户具有多个角色

    public ShiroUser() {
        super();
    }

    public ShiroUser(String username, String password) {
        super();
        this.username = username;
        this.password = password;
    }

//    @Transient
//    public Set<String> getRolesName() {
//        List<ShiroRole> roles = getRoleList();
//        Set<String> set = new HashSet<String>();
//        for (ShiroRole role : roles) {
//            set.add(role.getRoleName());
//        }
//        return set;
//    }

}